﻿<!-- #include file="mymin.asp" -->
<card title="回帖管理"><p>
<%

dim a,sql,rs,id,page
a=getN("a",0)
id=getN("id",0)
page=getN("page",1)

set rs=Server.CreateObject("ADODB.Recordset")

If a=0 Then
	rs.open"select r.id,r.content,r.userid,r.savetime,u.name from 74hu_reply r left join 74hu_user u on u.id=r.userid order by r.id desc",myconn,1,1
	If Not rs.eof	Then
		dim pagesize,count,i,pagecount
		PageSize=10
		Count=rs.recordcount
		if page<1 then page=1
		pagecount=(count+pagesize-1)\pagesize
		if page>pagecount then page=pagecount
		rs.move(pagesize*(page-1))
		w "共"&count&"篇帖子<br/>"
		For i=1 To PageSize
		If rs.eof Then Exit For
			w "[<a href=""replys.asp?sid="&sid&"&amp;id="&rs("id")&"&amp;a=1"">删除</a>]<a href='detail.asp?sid="&sid&"&amp;id="&rs("userid")&"'>"&_
				nowml(rs("name"))&"</a> "&forDate2(rs("savetime"))&" "&getLeft(nowml(rs("content")),30)&"<br/>"
			rs.moveNext
		Next
		w showPage("replys.asp", "", page, pageCount)
	Else
		w "暂时没有帖子！"
	end if
	rs.close
Elseif a=1 Then
	w "删除后无法恢复，而且会降低用户体验，你确定删除回帖？<br/><a href='replys.asp?sid="&sid&"&amp;id="&id&"&amp;page="&page&"&amp;a=2'>是,确定删除</a><br/><a href='replys.asp?sid="&sid&"&amp;page="&page&"'>否,返回管理</a><br/>"
Elseif a=2 Then
	rs.open "select * from 74hu_reply where id="&id,myconn,1,3
	If Not rs.eof Then
		myconn.Execute("update 74hu_user set reply=reply-1 where id="&rs("userid"))'删除回帖要将该会员回帖数-1
		myconn.Execute("update 74hu_topic set reply=reply-1 where id="&rs("postid"))'删除回帖要将该帖子回帖数-1
		rs.delete
		w "删除成功！<a href='replys.asp?sid="&sid&"&amp;page="&page&"'>返回管理</a>"
	Else
		w "回帖不存在！<a href='replys.asp?sid="&sid&"&amp;page="&page&"'>返回管理</a>"
	End If
	rs.close
Else
	w "操作失败！<a href='replys.asp?sid="&sid&"&amp;page="&page&"'>返回管理</a>"
End If

set rs=nothing

w "<br/>----------"
call bbsLast
%>